#qq空间日志删除
#定位element时候注意frame
from selenium import webdriver
from time import sleep
d=webdriver.Chrome(executable_path=r'D:\迅雷下载\chromedriver_win32\chromedriver.exe')
# d=webdriver.Firefox(executable_path=r'D:\迅雷下载\geckodriver-v0.23.0-win64\geckodriver.exe')
d.implicitly_wait(3)
d.set_window_position(20, 40)
d.set_window_size(1100,700)
d.get('https://user.qzone.qq.com/50937374')

# #登陆
d.switch_to_frame('login_frame')
d.find_element_by_css_selector('a.face:nth-child(2)').click()
d.switch_to_default_content()

##删除日志
##选择日志
d.find_element_by_css_selector('li.menu_item_2:nth-child(2) > a:nth-child(1)').click()
for i in range(100):
    sleep(5)
    d.switch_to_frame('tblog')
    #选择日志
    d.find_element_by_xpath('.//a[@class="c_tx3 arr_wrap"]').click()
    #选择删除日志
    d.find_element_by_css_selector('#more-tpl-list > ul:nth-child(1) > li:nth-child(1) > a:nth-child(1)').click()
    sleep(3)
    #切回默认frame
    d.switch_to_default_content()
    #切到delBlogFrame
    d.switch_to_frame('delBlogFrame')
    #确定删除
    d.find_element_by_css_selector('#btnConfirm').click()
    #回到默认frame
    d.switch_to_default_content()
d.close()